Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chapter-and-verse

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chapter-and-verse

Given a bible reference, validates it and returns an object with book, chapter, verse and more

  • 2.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33
increased by230%
Maintainers
1
Weekly downloads
 
Created
Source

chapter-and-verse

build coverage npm dependencies downloads

Given a bible reference, validates it and returns an object with book, chapter, verse and more


Introduction

Throw a bible reference at chapter-and-verse and, if valid, it returns a detailed JSON object for that reference.

If invalid, it returns a JSON object with the reason for failure.

chapter-and-verse understands all common bible book abbreviations and has its own built-in book identification algorithm.

It is useful when building biblical reference based URLs, for integrating with bible APIs and for validating raw user input.

chapter-and-verse is written by a professional developer, has 100% unit test coverage and is ready for production use.

All our biblical data has been triple checked to ensure reliability.

chapter-and-verse works in Node code and browsers.


Supported reference formats

chapter-and-verse supports all the following reference formats:

formatexamplenotes
bookGenesis
book chapterGenesis 5multi chapter books
book verseObadiah 3single chapter books
book versesObadiah 3-5single chapter books only
book chapter:verseGenesis 5:1
book chapter:versesGenesis 5:1-4

Usage

npm install --save chapter-and-verse

Usage:

const chapterAndVerse = require('chapter-and-verse')
let cv = chapterAndVerse('Dan 4:1-3')

And cv now looks like:

{
  "book": {
    "id": "Dan",
    "name": "Daniel",
    "testament": "O",
    "start": "dan",
    "abbr": ["da", "dn"],
    "chapters": 12,
    "versesPerChapter": [21, 49, 30, 37, 31, 28, 28, 27, 27, 21, 45, 13]
  },
  "success": true,
  "reason": "matches book.id",
  "chapter": 4,
  "from": 1,
  "to": 3
}

To validate a reference:

const chapterAndVerse = require('chapter-and-verse')
const ref = 'Dan 4:1-3'
let cv = chapterAndVerse(ref)
if (cv.success === true) {
  console.log(ref + ' is valid')
}
if (cv.success === false) {
  console.log(ref + ' is invalid because ' + cv.reason)
}

For more information see the Validation section.


Browser usage

npm install --save chapter-and-verse

Add a script tag in head:

<script src="node_modules/chapter-and-verse/browser.js"></script>

Then use as follows:

<script>
  const cv = chapterAndVerse('Gn')
  console.log(cv.book.name) // Genesis
</script>

You can validate a reference as described in the Usage section.


Methods

For a valid reference a number of methods are available.

Use cv.toString() and cv.toShortString() as follows:

cv = chapterAndVerse('Dan 4:1-3')
cv.toString() // returns 'Daniel 4:1-3'
cv.toShortString() // returns 'Daniel 4:1-3' .. no difference because Daniel is a multi chapter book

cv = chapterAndVerse('ob 1-3')
cv.toString() // returns 'Obadiah 1:1-3'
cv.toShortString() // returns 'Obadiah 1-3' .. difference because Obadiah is a single chapter book

cv.getType() returns one of 'book', 'chapter', 'verses' or 'verse'

Finally cv.toSimpleObject() provides access to a flat object containing only essential data:

cv = chapterAndVerse('exo 33:7-12')
cv.toSimpleObject()

Which returns:

{
  "type": "verses",
  "asString": "Exodus 33:7-12",
  "asShortString": "Exodus 33:7-12",
  "bookId": "Exod",
  "bookName": "Exodus",
  "testament": "O",
  "chapter": 33,
  "from": 7,
  "to": 12
}

Validation

chapter-and-verse returns a failure object if it cannot resolve the biblical reference:

{
  "book": {},
  "success": false,
  "reason": "book does not exist"
}

This happens when the:

chapter-and-verse does NOT recognise apocryphal books.


Accuracy of biblical data

All our chapter and verse data has been "triple checked" as follows:

(1) The data was entered manually and manually checked.

(2) We then ran code against our data, ensuring verse and chapter totals were correct.

(3) Finally, we programmatically tested our data against other online sources to ensure "total agreement".


Translation specifics

Certain verses only exist in certain translations.

  • 3 John 15

chapter-and-verse reports 3 John 15 as valid. However, this verse does not exist in the KJV wherein it has been merged with 3 John 14.

This is the only chapter-and-verse discrepancy with the KJV.

Compare 3 John 14-15 ESV with 3 John 14 KJV

  • Omitted verses

In modern English translations, certain New Testament verses, which exist in the KJV, have been omitted.

For example Matthew 17:21 ESV does not exist whereas Matthew 17:21 KJV does exist.

chapter-and-verse treats all omitted verses as valid and is not concerned with translation specifics.

For an in-depth discussion see omitted verses


Author says

The Lord bless you and keep you;

the Lord make his face to shine upon you and be gracious to you;

the Lord lift up his countenance upon you and give you peace.

Numbers 6:24-26 ESV




Keywords

FAQs

Package last updated on 17 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc